<!--顶部导航栏-->
<template>
    <div class="TopComponent-max-div">
      <div class="top-max-div">

        <div style="position: absolute;left: 8%;top: 18%;color: #FFFFFF;">

          <el-tooltip placement="bottom" effect="light">
            <template #content>
              <div v-html="updataHtml ? updataHtml.replace(/\n/g,'<br/>') : ''"></div>
            </template>
            <div style="cursor: pointer">
              <div style="font-size: 22px;font-family: emoji;font-weight: 900;">企业项财一体化应用门户</div>
              <div style="font-size: 14px;letter-spacing: 2px;text-align: center">内蒙古和利管理咨询集团有限公司</div>
            </div>
          </el-tooltip>
        </div>

        <div class="left-nav-box">
          <div style="display: flex;align-items: center;justify-content: space-between;">
            <div style="display: flex;align-items: center;justify-content: space-evenly;min-width: 252px;">
              <div style="font-size: 14px;font-weight: 400;">
                <div class="name" style="text-align: right">
                   <span>{{ userInfo.nickName }}<!--<span v-if="userInfo.dept.prop == '0'"> | {{ userInfo.dept.deptName }}</span> --></span>
                </div>
                <div class="company" style="float: right;">
                  <span>{{ userInfo.gsName }}</span>
                </div>
              </div>
              <el-image :src="userInfo.avatar ? userInfo.avatar : Group" alt="" class="avator"></el-image>
            </div>
            <div style="cursor: pointer;" @click="aa => {
              passwordForm = {
                newPassword1: '',
                newPassword2: '',
              }
              dialogFormVisible = true
            }">
              <div>修改密码</div>
            </div>
            <div class="loginOut">
              <img src="../../../assets/images/loginout.png" alt="" class="tuichu">
              <div @click="logout()">退出登录</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <el-dialog title="修改密码" v-model="dialogFormVisible">
      <el-form :model="passwordForm">
        <el-form-item label="新密码" :label-width="formLabelWidth">
          <el-input placeholder="请输入新密码" v-model="passwordForm.newPassword1" show-password></el-input>
        </el-form-item>
        <el-form-item label="确认密码" :label-width="formLabelWidth">
          <el-input placeholder="请再次确认密码" v-model="passwordForm.newPassword2" show-password></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="passwordSubmit">确 定</el-button>
        </div>
      </template>
    </el-dialog>
    <noticeTitle ref="childRef"></noticeTitle>
</template>

<script setup name="TopComponent">
import { onMounted , onBeforeUnmount, computed } from 'vue';
import { useRouter } from 'vue-router';
import { useFullscreen , useDark } from '@vueuse/core';
import { useLayoutConfigStore } from '@/stores/layoutConfig';
import { useAuthStore } from '@/stores/auth';
const router = useRouter();

const layoutConfig = useLayoutConfigStore();

const authStore = useAuthStore();
const userInfo = computed(() => authStore.userInfo);
// import { todoMessageList } from '@/api/notice'
// import cache from "@/plugins/cache";
// import { getUpdateMessage, updatePwd } from '@/api/login'
// import noticeTitle from "@/components/Breadcrumb/noticeTitle.vue";

// export default {
//   name: 'TopComponent',
//   components: {noticeTitle},
//   data() {
//     return {
//       Group: require('../../../assets/images/Group.png'),
//       dialogFormVisible: false,
//       passwordForm: {
//         newPassword1: '',
//         newPassword2: '',
//       },
//       formLabelWidth: '120px',
//       input: '',
//       listContentTotal: this.$store.state.user.listContentTotal || 0,
//       userInfo: {},
//       updataHtml: '',
//     }
//   },
//   created() {
//     this.userInfo = this.$store.state.user.userInfo
//     this.updateMessage() // 检查更新
//     this.getNoticeMessage()
//     // 循环定时器
//     setInterval(() => {
//       this.getNoticeMessage()
//     }, 60000)
//   },
//   methods: {
//     updateMessage(){
//       getUpdateMessage().then(res => {
//         this.updataHtml = res.data.psMessage
//       })
//     },
//     gslength(str){
//       if(str.length>13){
//         return str.substring(0,13)+"..."
//       }else{
//         return str
//       }
//     },
//     passwordSubmit() {
//       if (this.passwordForm.newPassword1 === '') {
//         this.$message.error('请输入新密码')
//         return
//       }
//       if (this.passwordForm.newPassword2 === '') {
//         this.$message.error('请再次确认密码')
//         return
//       }
//       if (this.passwordForm.newPassword1 !== this.passwordForm.newPassword2) {
//         this.$message.error('两次密码不一致')
//         return
//       }
//       this.$confirm('是否确认修改密码?', '提示', {
//         confirmButtonText: '确定',
//         cancelButtonText: '取消',
//         type: 'warning'
//       }).then(() => {
//         updatePwd(this.passwordForm).then(() => {
//           this.$message.success('修改成功！')
//           setTimeout(() => {
//             this.$store.dispatch('LogOut').then(() => {
//               location.href = '/login';
//             })
//           }, 1000)
//           this.dialogFormVisible = false
//         })
//       }).catch(() => {
//         this.$message.info('已取消修改')
//       })
//     },
//     gotoLink(item) {
//       this.isActive = item.key
//       // 如果是1能点,否则不能点
//       if (item.status === '0') {
//         if (item.isFrame === "1") {
//           this.$router.push(item.path + "/homePage")
//         } else {
//           window.open(item.path, '_blank')
//         }
//       } else {
//         this.$message.info('正在开发')
//       }
//     },
//     goNoticeList(type){
//       this.$refs.childRef.noticeTodoList();
//     },
//     /** 查询消息 */
//     getNoticeMessage(){
//       this.loading = true;
//       todoMessageList({"noticeType":"1",readFlag:0,groupId: null}).then(response => {
//         this.$store.commit('SET_LISTCONTENTTOTAL', response.data.totalCount);
//         this.loading = false;
//       });
//     },
//     logout() {
//       this.$modal.confirm("是否确认退出登录").then(()=>{
//         this.$store.dispatch('LogOut').then(() => {
//           location.href = '/login';
//         })
//       })
//     },
//   }
// }
</script>

<style scoped lang="scss">
.TopComponent-max-div {
  box-sizing: border-box;

  .top-max-div {
    // justify-content: space-between;
    // align-items: center;
    background: url(../../../assets/images/headImg.png) no-repeat;
    background-size: cover;
    width: 100%;
    height: 78px;
    position: relative;
    // display: flex;
    // justify-content: space-around;

    .left-nav-box {
      position: absolute;
      right: 55px;
      top: 20px;
      color: #FFFFFF;
      width: 520px;
      .el-input {
        width: 272px;
        height: 32px;
        background: #FFFFFF;
        border-radius: 50px;
      }
      .xiaoxi{
        width: 20px;
        height: 20px;
        position: relative;
        top: 3px;
        left: -3px;
        // margin: 7px 15px;

      }
      .tuichu{
        width: 18px;
        height: 18px;
        margin-right: 5px;
        //position: relative;
        //top: 7px;
        //left: 46px;
      }
      .avator{
        width: 34px;
        height: 34px;
        border-radius: 100%;
        margin-left: 5px;
      }
      .btn {
        border: 1px solid #fff;
        border-radius: 10px;
        color: #333333;
        //position: relative;
        //top: 7px;
        //left: 65px;

      }

      .loginOut {
        //position: relative;
        //top: -9px;
        //left: 54px;
        display: flex;
        align-items: center;
        cursor: pointer;
      }
    }

    // .right-person-box {
    //   display: flex;
    //   justify-content: flex-end;
    //   align-items: center;
    //   gap: 100px;
    //   margin-right: 10px;
    //   // 个人信息
    //   .info-box {
    //     display: flex;
    //     gap: 30px;

    //     .info-box-item {
    //       display: flex;
    //       gap: 5px;
    //       color: #fff;
    //     }

    //     .username-box {
    //       color: #fff;
    //     }
    //   }

    //   .drop-user-box {
    //     color: #303133;
    //     font-size: 18px;
    //   }
    // }
  }
}

.centerContent {
  height: 262px;
  background: #fff;
  margin: 15px;

  .nav-box {
    width: 170px;
    height: 212px;
    background: #fff;
    border-radius: 10px;
    margin: 25px 33px;
    background: #FFFFFF;
    box-shadow: 0px 0px 20px 2px rgba(24, 97, 180, 0.06);

    .nav-content {
      margin: 5px 27px;

      .nav-text {
        font-size: 22px;
        color: black;
        cursor: pointer;
        padding: 0px 10px;
      }

      .title {
        line-height: 10px;
        padding-left: 15px;
      }

      .img {
        margin: 21px 29px;
      }
      .no-ointer-events {
        font-size: 22px;
        color: black;
        cursor: not-allowed;
        padding: 0px 10px;
        opacity: 0.6;
      }
    }

    &:hover {
      border-bottom: 2px solid #ffffff;
      padding-bottom: 2px;
    }
  }
}
</style>
